package com.springboot.controller;

import com.springboot.domain.Student;
import com.springboot.service.TestServiceI;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Controller
@RequestMapping("t1c")
public class Test1Controller {

    @Resource(name="testServiceI")
    private TestServiceI tsi;

    @RequestMapping("/t1")
    public String t1(){
        return "/view/t1.html";
    }

    @RequestMapping("/t2")
    @ResponseBody
    public String t2(){
        return "hqj good good de";
    }

    @RequestMapping("/t3")
    @ResponseBody
    public List<String> t3(){
        List<String> list = new ArrayList<>();
        list.add("abc");
        list.add("红旗街");
        list.add("123");
        return list;
    }

    @RequestMapping("/t4")
    public String t4(ModelMap mmap){
        String name = "hqj123";
        //响应数据到页面
        mmap.addAttribute("name",name);
        return "/view/t2.html";
    }

    @RequestMapping("/t5")
    public String t5(ModelMap mmap){
        List<Student> list = tsi.findStudent();
        mmap.addAttribute("stus",list);
        return "/view/t3.html";
    }
}
